<?php
/**
 * 《脚本运行》批处理
 * 
 * @author 孙晓晔
 * @version $Id: t.php 419 2009-10-28 04:33:29Z sunxy $
 */

if (!defined('APP_ROOT')) define('APP_ROOT', dirname(__FILE__) . "/../");
if (!defined('APP_INC')) define('APP_INC', APP_ROOT . '/../../inc/');
if (!defined('APP_LIB')) define('APP_LIB', APP_ROOT . '/../../lib/');

require_once(APP_ROOT . '/inc/config.php');
require_once(APP_LIB . 'Controller.class.php');

$controller = new Controller();
$controller->config = APP_ROOT . '/inc';

$controller->left_delimiter = "{[";
$controller->right_delimiter = "]}";

// if (count($argv) >= 3) {
// 	$controller->import = APP_ROOT . '/lib/' . $argv[1] . '/';
// 	$_REQUEST['do'] = $argv[2];
// } else {
// 	$controller->import = APP_ROOT . '/lib/';
// 	$_REQUEST['do'] = $argv[1];
// }

$cmd = array(
	array('dir'=>'tel', 'do'=>'Mobile.cdr'),
	array('dir'=>'tel', 'do'=>'Mobile.k780'),
		
	array('dir'=>'log', 'do'=>'LogAction.tj'),
	array('dir'=>'log', 'do'=>'LogAccess.tj'),
	array('dir'=>'log', 'do'=>'Vlog.a'),
	array('dir'=>'log', 'do'=>'Vlog.tj'),
	array('dir'=>'log', 'do'=>'Vlog.tj2'),
		
	array('dir'=>'emp', 'do'=>'Emp.ldap'),
	array('dir'=>'emp', 'do'=>'Emp.tj1'),
	array('dir'=>'emp', 'do'=>'Emp.tj3'),
	array('dir'=>'emp', 'do'=>'Emp.tj4'),
	array('dir'=>'emp', 'do'=>'EmpBank.z'),
	array('dir'=>'emp', 'do'=>'Vpopmail.ftp'),
	
	array('dir'=>'emp', 'do'=>'Mac.ns2'),
	array('dir'=>'emp', 'do'=>'Exten.u'),
	array('dir'=>'emp', 'do'=>'Contract.tj'),
	
	array('dir'=>'contact', 'do'=>'Supplier.tj'),
	array('dir'=>'contact', 'do'=>'Supplier.c'),
	array('dir'=>'contact', 'do'=>'Customer.c'),
	
	array('dir'=>'car', 'do'=>'Requirement.tj'),
	
	array('dir'=>'finance', 'do'=>'Borrow.n3'),
	array('dir'=>'finance', 'do'=>'Borrow.tj1'),
	
	array('dir'=>'finance', 'do'=>'Expense.tj1'),
	array('dir'=>'finance', 'do'=>'Payment.tj1'),
	array('dir'=>'finance', 'do'=>'Payment.star'),
	
	array('dir'=>'finance', 'do'=>'Invest.tj'),
	
	array('dir'=>'finance', 'do'=>'Transaction.tj'),
	array('dir'=>'finance', 'do'=>'Transaction.star'),
	array('dir'=>'finance', 'do'=>'Transaction.po'),
	
	array('dir'=>'finance', 'do'=>'In.z_status'),
	array('dir'=>'finance', 'do'=>'InItem.tj'),
	array('dir'=>'finance', 'do'=>'InItem.z'),
	array('dir'=>'finance', 'do'=>'InItem.b'),
	
	array('dir'=>'finance', 'do'=>'Out.z_status'),
	array('dir'=>'finance', 'do'=>'OutItem.tj'),
	array('dir'=>'finance', 'do'=>'OutItem.b'),
	
	array('dir'=>'finance', 'do'=>'Bank.tj'),
	array('dir'=>'finance', 'do'=>'Asset.tj1'),
	array('dir'=>'finance', 'do'=>'Scrap.tj1'),
	
	array('dir'=>'info', 'do'=>'Note.tj'),
	array('dir'=>'info', 'do'=>'Conference.tj1'),
	array('dir'=>'info', 'do'=>'Contact.ldap'),
	
	array('dir'=>'customer', 'do'=>'Email.tj'),
	array('dir'=>'customer', 'do'=>'Quote.tj'),
	array('dir'=>'customer', 'do'=>'Quote.tjbj'),
	
	array('dir'=>'contact', 'do'=>'Customer.tj'),
	array('dir'=>'express', 'do'=>'Requirement.tj'),
	
	array('dir'=>'material', 'do'=>'Receive.day_update'),
	array('dir'=>'material', 'do'=>'Material.sync_category'),
	array('dir'=>'material', 'do'=>'RecordIn.sync_price'),
	array('dir'=>'material', 'do'=>'Amount.amount_zero'),
	
);

while (list($k, $v) = each($cmd)) {
	// $controller->import = APP_ROOT . '/lib/' . $k . '/';
	$controller->import = sprintf("%s/%s/%s/", APP_ROOT, 'lib', $v['dir']);
	$_REQUEST['do'] = $v['do'];
	
	// print_r($_REQUEST);
	$_REQUEST['_tec'] = $argv;
	$controller->execute($_REQUEST);
}

?>
